{extend name="layout/layout" /}

{block name="pagecss"}
<style>
    input[type="checkbox"]{
        margin-left: 8px;
    }
</style>
{/block}

{block name="content"}
<div class="row">
    <div class="col-xs-12">
        <div class="box box-success">
            <div class="box-header with-border">
                <h3 class="box-title">编辑代金券</h3>
                <div class="box-tools">
                    <!--<button class="btn bg-navy btn-sm" data-toggle="tooltip" title="" data-original-title="Back" onclick="history.go(-1);">
                        <i class="fa fa-reply"></i> 返回
                    </button>-->
                </div>
            </div>
            <div class="box-body">
                <form id="modal_new_role" class="form-horizontal form" method="post" enctype="multipart/form-data">
                    <div class="form-body">
                        <div class="form-group">
                            <div class="col-md-5">
                                <span class="help-block text-center"></span> <input type="hidden" name="storeId" value="{$row.storeId}"><input type="hidden" name="id" value="{$row.id}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label"> 所属门店:
                            </label>
                            <div class=" col-lg-4">
                                <input type="text" class="form-control" disabled value="{$storeName}" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label"> <span class="required"> * </span>代金券名称:
                            </label>
                            <div class=" col-lg-4">
                                <input type="text" class="form-control" name="name" maxlength="15" value="{$row.name}" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label"> <span class="required"> * </span>面值金额:
                            </label>
                            <div class=" col-lg-2">
                                <input type="text" class="form-control" name="value2" maxlength="4" value="{$row.value2/100}" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
                            </div>
                            <span class="form-control-static pull-left"> 元 </span>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label"> <span class="required"> * </span>有效期:
                            </label>
                            <div class=" col-lg-2">
                                <input type="text" class="form-control" placeholder="生效时间" id="startTime" name="startTime" value="{$row.startTime|date='Y-m-d',###}">
                            </div>
                            <div class=" col-lg-2">
                                <input type="text" class="form-control" placeholder="过期时间" id="endTime" name="endTime" value="{$row.endTime|date='Y-m-d',###}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label">使用时段:
                            </label>
                            <div class="col-md-6">
                                {foreach name="week" item="vo" }
                                <input {in name="key" value="$row.useWeek"}checked{/in}  name="useWeek" type="checkbox" value="{$key}">{$vo}
                                {/foreach}
                                <div class="datatime">
                                    <div class="col-md-4 datatimebox">
                                        <input class="form-control input-min" type="text" value="{$row.dayStartTime}" onClick="WdatePicker({dateFmt:'HH:mm'})" readonly="readonly" name="dayStartTime">
                                    </div>
                                    <div class="col-md-1"> ~ </div>
                                    <div class="col-md-4 datatimebox">
                                        <input class="form-control input-min" type="text" name="dayEndTime" value="{$row.dayEndTime}" onClick="WdatePicker({dateFmt:'HH:mm'})" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label"> <span
                                    class="required"> * </span> 使用限制:
                            </label>
                            <div class="col-lg-6 col-xs-12">
                                <label class=" ">
                                    <input type="radio" name="type" {eq name="row.type" value="无限制"}checked{/eq} value="无限制">无限制
                                </label>
                            </div>

                        </div>
                        <div class="form-group">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-6 col-xs-12">
                                <label class="pull-left form-control-static">
                                    <input type="radio" name="type" value="消费满减" {eq name="row.type" value="消费满减"}checked{/eq}  >消费满
                                </label>
                                <div class="col-lg-4 col-xs-12">
                                    <input type="text" class="form-control" id="zhekou" placeholder="金额数字,不含小数点" name="value1" {eq name="row.type" value="无限制"}disabled{/eq} maxlength="6" value="{$row.value1/100}" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
                                </div>
                                <span class="form-control-static pull-left">元, 即可使用</span>
                            </div>
                        </div>
                        <div class="form-group" >
                            <label class="col-lg-2 control-label"> <span class="required"> * </span> 获取条件:
                            </label>
                            <div class="col-lg-6 col-xs-12 changeGetCond">
                                <label class="pull-left form-control-static margin-right">
                                    <input type="radio" name="getCond" value="1" {eq name="row.getCond" value="1"}checked{/eq}  >用户手动领取
                                </label>
                                <label class="pull-left form-control-static margin-right">
                                    <input type="radio" name="getCond" value="3" {eq name="row.getCond" value="3"}checked{/eq}  >完成订单消费赠送
                                </label>
                            </div>

                        </div>

                        <div class="xqClass cond1">
                            <div class=" form-group">
                                <label class="col-lg-2 control-label"></label>
                                <div class="col-md-2 " >领取总量:</div>
                                <div class="col-md-2 " >
                                    <input type="text" class="form-control" placeholder="" name="totalCount" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" value="{$row.totalCount}" maxlength="8">
                                </div>
                                <span class="form-control-static pull-left">张  <input {eq name="row.isLimit" value="1"}checked{/eq}  type="checkbox" name="isLimit1" value="1">无限量</span>
                            </div>
                            <div class=" form-group">
                                <label class="col-lg-2 control-label"></label>
                                <div class="col-md-2 " >每人限领:</div>
                                <div class="col-md-2 " >
                                    <input type="text" class="form-control" placeholder="" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" name="maxGet"  value="{$row.maxGet}" maxlength="8">
                                </div>
                                <span class="form-control-static pull-left">张，使用后可再次领取</span>
                            </div>
                            <div class=" form-group">
                                <label class="col-lg-2 control-label"></label>
                                <div class="col-md-2"><input type="checkbox" name="isGetPhone" {eq name="row.isGetPhone" value="1"}checked{/eq} value="1">领取时获取手机号</div>
                            </div>
                        </div>

                        <div class="xqClass cond2 form-group" style="display: none">
                            <div class="form-group">
                                <label class="col-lg-2 control-label"></label>
                                <div class="col-md-2 " >订单金额:</div>
                                <div class="col-md-2 " >
                                    <input type="text" class="form-control" placeholder="金额数字,不含小数点" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" name="condValue1"  value="{$row.condValue1/100}" maxlength="8">
                                </div>
                                <span class="form-control-static pull-left">至</span>
                                <div class="col-md-2 " >
                                    <input type="text" class="form-control" placeholder="金额数字,不含小数点" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" name="condValue2"  value="{$row.condValue2/100}" maxlength="8">
                                </div>
                                <span class="form-control-static pull-left">元</span>
                            </div>
                            <div class=" form-group">
                                <label class="col-lg-2 control-label"></label>
                                <div class="col-md-2 " >赠送总量:</div>
                                <div class="col-md-2 " >
                                    <input type="text" class="form-control" placeholder="" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" name="totalCount"  value="{$row.totalCount}" maxlength="8">
                                </div>
                                <span class="form-control-static pull-left">张  <input {eq name="row.isLimit" value="1"}checked{/eq}  type="checkbox" name="isLimit2" value="1">无限量</span>
                            </div>
                            <div class=" form-group">
                                <label class="col-lg-2 control-label"></label>
                                <div class="col-md-2 " >每人限送:</div>
                                <div class="col-md-2 " >
                                    <input type="text" class="form-control" placeholder="" name="maxGet" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" value="{$row.maxGet}" maxlength="8">
                                </div>
                                <span class="form-control-static pull-left">张</span>
                            </div>
                        </div>

                        <hr />

                        <div class="form-actions">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-md-3 control-label"></label>
                                        <div class="col-md-9">
                                            <button type="button" id="save" class="btn btn-primary">
                                                保存 <i class="fa fa-floppy-o"></i>
                                            </button>
                                            <button type="button" id="btn_cancle" class="btn btn-default" onclick="history.go(-1);">
                                                返回 <i class="fa fa-mail-forward"></i>
                                            </button>
                                            <span class="help-block "></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="pagescript"}
<script src="__STATIC__/plugins/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/include.js" type="text/javascript"></script>
<script>
    var index_url = "{:url('admin/coupon/index')}";   //代金券列表页
    var list_url = "{:url('admin/coupon/indexApi')}";   //获取代金券列表
    var add_url = "{:url('admin/coupon/add')}";  //添加新的代金券
    var savePost_url = "{:url('admin/coupon/savePost')}";  //添加新的代金券提交地址
</script>
<script src="__STATIC__/admin/pages/js/coupon.js" type="text/javascript"></script>
{/block}